<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title>驴友网后台-用户信息</title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
	<form method="post" action="">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">用户管理</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search">
					<li>
						<button type="button" class="button border-green" id="checkall">
							<span class="icon-check"></span> 全选
						</button>
						<button type="submit" class="button border-red">
							<span class="icon-trash-o"></span> 批量删除
						</button>
					</li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th width="120">ID</th>
					<th>头像</th>
					<th>用户名</th>
					<th>电话</th>
					<th>邮箱</th>
					<th>本站积分</th>
					<th>头衔</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
				<%--循环遍历用户信息 --%>
				<c:forEach var="list" items="${sessionScope.info }"
					varStatus="status">
					<tr>
						<td><input type="checkbox" name="id[]" value="1" />
							${status.count}</td>
						<td><img src="${list.value.headPortrait}"
							style="width: 80px;height: 80px;"></td>
						<td>${list.key.username}</td>
						<td>${list.key.phonenumber}</td>
						<td>${list.key.mail}</td>
						<td>${list.value.score }</td>
						<td style="color:#979B18;">${list.value.touxian }</td>
						<td style="color:#C11D2D;">${list.value.state }</td>
						<c:choose>
							<c:when test="${list.value.state.equals('禁用') }">
								<td><div class="button-group">
										<a class="button border-main" href="<c:url value='/unlockUserServlet'/>?name=${list.value.username}"
											onclick="return unlock();"><span class="icon-edit"></span>
											解封</a> <a class="button border-red"
											href="<c:url value='/deleteUserServlet'/>?name=${list.value.username}"
											onclick="return del()"><span class="icon-trash-o"></span>
											删除</a>
									</div></td>
							</c:when>
							<c:otherwise>
								<td><div class="button-group">
										<a class="button border-red" href="<c:url value='/forbidUserServlet'/>?name=${list.value.username}"
											onclick="return forbid();"><span class="icon-edit"></span>
											禁用</a> <a class="button border-red"
											href="<c:url value='/deleteUserServlet'/>?name=${list.value.username}"
											onclick="return del()"><span class="icon-trash-o"></span>
											删除</a>
									</div></td>
							</c:otherwise>
						</c:choose>

					</tr>
				</c:forEach>

				<tr>
					<td colspan="9"><div class="pagelist">
							<a href="">上一页</a> <span class="current">1</span><a href="">2</a><a
								href="">3</a><a href="">下一页</a><a href="">尾页</a>
						</div></td>
				</tr>
			</table>
		</div>
	</form>
	<script type="text/javascript">
		function forbid() {
			if (confirm("您确定要禁用该用户吗？")) {
				return true;
			} else {
				return false;
			}
	
		}
		function unlock() {
			if (confirm("您确定要解封该用户吗？")) {
				return true;
			} else {
				return false;
			}
		}
		function del(id) {
			if (confirm("您确定要删除吗?")) {
				return true;
			} else {
				return false;
			}
		}
	
		$("#checkall").click(function() {
			$("input[name='id[]']").each(function() {
				if (this.checked) {
					this.checked = false;
				} else {
					this.checked = true;
				}
			});
		})
	
		function DelSelect() {
			var Checkbox = false;
			$("input[name='id[]']").each(function() {
				if (this.checked == true) {
					Checkbox = true;
				}
			});
			if (Checkbox) {
				var t = confirm("您确认要删除选中的内容吗？");
				if (t == false) return false;
			} else {
				alert("请选择您要删除的内容!");
				return false;
			}
		}
	</script>
</body>
</html>